'''
Log file utility.

Created on April, 2012
@author: bruce
'''

from datetime import datetime, date

class LogFile:    
    def __init__(self, __outputFile, module="EmptyModule"):
        outputPath = "logs\\" + __outputFile + "-" + str(date.today())
        self.__outputFile = open(outputPath, 'w')
        self.__module = module
    
    """
    Provide a detailed log with current time, module name, severity in the context.
    """
    def detail_log(self, severity, outputContent):
        currentTime = datetime.now()
        self.__outputFile.write(str(currentTime) + '['+ self.__module + ']' + '|'+ severity + '|  \t'+ outputContent + "\n")    
        self.__outputFile.flush()
    
    """
    Provide a plain log.
    """    
    def plain_log(self, outputContent):
        self.__outputFile.write(outputContent+"\n")    
        self.__outputFile.flush()
    
    """
    Close the log file
    """
    def closelog(self):
        self.__outputFile.close()